Clean docs and add Plausible tracking#2
Conversation
Amp-Thread-ID: https://ampcode.com/threads/T-019f25c9-6992-767a-95b0-ae59792f6e84 Co-authored-by: Adam Krupa <adam00krupa@gmail.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
📝 WalkthroughWalkthroughThis PR adds Plausible Analytics integration, wires it into app startup, updates Vite/type support for the tracker and env var, and revises deployment notes and roadmap docs. ChangesPlausible Analytics Integration
Estimated code review effort: 2 (Simple) | ~10 minutes Sequence Diagram(s)sequenceDiagram
participant MainTsx as main.tsx
participant AnalyticsModule as analytics.ts
participant PlausibleTracker as `@plausible-analytics/tracker`
MainTsx->>AnalyticsModule: import ./analytics
AnalyticsModule->>AnalyticsModule: read VITE_PLAUSIBLE_DOMAIN
alt domain is set and window exists
AnalyticsModule->>PlausibleTracker: init({ domain, outboundLinks: true })
else domain is missing or init already ran
AnalyticsModule-->>MainTsx: no-op
end
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
✨ Simplify code
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/analytics.ts (1)
1-10: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick winGuard
init()so a tracker failure can't break app startup.
analytics.tsis imported beforecreateRoot(...).render(...)inmain.tsx. Ifinit()throws (misconfigured domain, packaging/resolution issue, browser API unavailability), it aborts module evaluation and the whole app fails to mount, for what is purely an optional analytics feature.🛡️ Proposed fix
const plausibleDomain = import.meta.env.VITE_PLAUSIBLE_DOMAIN; if (plausibleDomain) { - init({ - domain: plausibleDomain, - outboundLinks: true, - }); + try { + init({ + domain: plausibleDomain, + outboundLinks: true, + }); + } catch { + // analytics is best-effort; never block app startup + } }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/analytics.ts` around lines 1 - 10, `analytics.ts` currently calls `init()` during module evaluation, so any tracker failure can stop app startup before `main.tsx` reaches `createRoot(...).render(...)`. Wrap the `init()` call in a narrow try/catch (or move it into a safe bootstrap helper) so optional analytics errors are swallowed or logged without aborting app mount, and keep the guard tied to `plausibleDomain` in `analytics.ts`.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@package.json`:
- Line 21: The dependency pin for `@plausible-analytics/tracker` is still on
0.4.5, which is the version affected by the Vite entry-resolution issue. Update
the version in package.json to a release that includes the exports fix, and make
sure src/analytics.ts continues to import the package at module scope without
triggering the bug.
---
Nitpick comments:
In `@src/analytics.ts`:
- Around line 1-10: `analytics.ts` currently calls `init()` during module
evaluation, so any tracker failure can stop app startup before `main.tsx`
reaches `createRoot(...).render(...)`. Wrap the `init()` call in a narrow
try/catch (or move it into a safe bootstrap helper) so optional analytics errors
are swallowed or logged without aborting app mount, and keep the guard tied to
`plausibleDomain` in `analytics.ts`.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 06bba33e-c715-48d2-8279-0e17239fe57a
⛔ Files ignored due to path filters (1)
bun.lockis excluded by!**/*.lock
📒 Files selected for processing (14)
.env.local.exampleAGENTS.mdNEXT.mdREADME.mddocs/archive/flash-experiments-handoff-2026-06-29.mddocs/archive/initial-mvp-prompt.mddocs/archive/theo-team-communication-brief.mddocs/design.mddocs/next.mddocs/product.mdpackage.jsonsrc/analytics.tssrc/main.tsxsrc/vite-env.d.ts
💤 Files with no reviewable changes (1)
- NEXT.md
There was a problem hiding this comment.
2 issues found across 15 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
There was a problem hiding this comment.
🧹 Nitpick comments (1)
vite.config.ts (1)
4-16: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winUse the package specifier here instead of a deep
node_modulespath.@plausible-analytics/trackeralready exposes a normal entrypoint, so this alias can just resolve the package itself. That keeps the config independent of the package’s internal file layout and avoids a future break if the published artifact path changes.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@vite.config.ts` around lines 4 - 16, The Vite alias for `@plausible-analytics/tracker` is pointing to a deep node_modules file path instead of the package entrypoint. Update the alias setup in vite.config.ts so the `@plausible-analytics/tracker` specifier resolves directly to the package name rather than using fileURLToPath/new URL for plausible.js, keeping the config tied to the public package API.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@vite.config.ts`:
- Around line 4-16: The Vite alias for `@plausible-analytics/tracker` is pointing
to a deep node_modules file path instead of the package entrypoint. Update the
alias setup in vite.config.ts so the `@plausible-analytics/tracker` specifier
resolves directly to the package name rather than using fileURLToPath/new URL
for plausible.js, keeping the config tied to the public package API.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 1ca7b767-f8b1-453a-8256-930ef067e1ec
📒 Files selected for processing (2)
src/analytics.tsvite.config.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- src/analytics.ts
Summary
Verification
Summary by cubic
Reorganized docs under
docs/and archived historical notes. Added optional, env-gated Plausible Analytics for the demo domain with safe, idempotent, browser-only init; updated Vercel build/deploy guidance.New Features
@plausible-analytics/tracker(package entrypoint) with outbound link tracking; initializes only in the browser whenVITE_PLAUSIBLE_DOMAINis set.src/analytics.tsimported insrc/main.tsx; addedVITE_PLAUSIBLE_DOMAINtyping insrc/vite-env.d.ts.docs/product.mdanddocs/design.md; addeddocs/next.md. Extended.env.local.example.Migration
VITE_PLAUSIBLE_DOMAIN=postwork.pcstyle.dev, add that domain under Project → Domains, redeploy, then verify in Plausible.bunx convex deploy --cmd-url-env-var-name VITE_CONVEX_URL --cmd 'bun run build'(do not setVITE_CONVEX_URLmanually).VITE_PLAUSIBLE_DOMAINin.env.local.Written for commit d705f4c. Summary will update on new commits.